import BookForm from "@/components/BookForm";
import { useEffect, useState } from "react";
import { useRouter } from 'next/router';
import { getBookDetails } from '@/api/book'

export default function BookEdit() {
    const router = useRouter();
    const [editData, set_editData] = useState({});
    useEffect(() => {
        const fetchData = async () => {
            const { id } = router.query;
            if (id) {
                const res = await getBookDetails(id as any);
                set_editData(res.data);
            }
        }
        fetchData();
    }, [router])
    return <BookForm title={'图书编辑'} editData={editData} />
}
